<?php
	class models_hoadon extends connect{
		function _listHoaDonn(){
			$sql = "SELECT MaHD, MaKH, NgayLap, NguoiLap
					FROM hoadon";
			$this->query_db($sql);
			return $this->fetchAll();
		}
		function _addHoaDon($MaKH,$NgayLap,$NguoiLap){
			$sql = "INSERT INTO hoadon VALUES ('','$MaKH','$NgayLap','$NguoiLap')";
			$this->query_db($sql);
		}
		function _delHoaDon($id){
			$sql = "DELETE 
					FROM hoadon
					WHERE MaHD = '$id'";
			$this->query_db($sql);
		}
		function _getHoaDon($id){
			$sql  = "SELECT MaHD, MaKH, NgayLap, NguoiLap
					 FROM hoadon
					 WHERE MaHD = '$id'";
			$this->query_db($sql);
			return $this->fetchOne();
					
		}
		function _editHoaDon($MaKH, $NgayLap, $NguoiLap, $id){
			$sql = "UPDATE hoadon
					SET 
						MaKH = '$MaKH',
						NgayLap = '$NgayLap',
						NguoiLap = '$NguoiLap'
					WHERE MaHD = '$id'";
			$this->query_db($sql);
		}
	}
?>